package com.turtle3d.user.visualizators;

import java.util.ArrayList;

import javax.media.j3d.BranchGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;

import com.turtle3d.formallanguage.VisualSymbol;
import com.turtle3d.formallanguage.symbol.Symbol;
import com.turtle3d.visualizator.Line3D;
import com.turtle3d.visualizator.VisualData;
import com.turtle3d.visualizator.Visualizator;

public class Line extends Visualizator
{

	public BranchGroup visualize(VisualData visualData)
	{
		BranchGroup branchGroup = new BranchGroup();
		
		ArrayList<VisualSymbol> visualSequence = visualData.getVisualSequence();
				
		for(int i=0;i<visualSequence.size();i++){
			
			if(!visualSequence.get(i).getSymbol().equals(new Symbol("F")))
				continue;								
			
			Float d = visualSequence.get(i).getSymbol().getParameter("distance");			
					
			Point3f p1 = new Point3f(0,0,0);
			Point3f p2 = new Point3f(0,d,0);						
																																				
			Line3D c = new Line3D(p1, p2 , new Color3f(1f,1f,1f));
							
			branchGroup.addChild(createTransformGroup(visualSequence.get(i).getTransform(), c.toShape3D()));
			
		}					
		
		return branchGroup;
	}

}
